<?php
    session_start();
    if(isset($_COOKIE['Success'])){
        if($_COOKIE['Success']=="ThemTC"){
        echo "<script type='text/javascript'> 
          alert('Thêm thành công 1 nhóm nhân viên mới!');
          </script>";
        }
        if($_COOKIE['Success']=="XoaTC"){
        echo "<script type='text/javascript'> 
          alert('Xóa thành công 1 nhóm nhân viên!');
          </script>";
        }
    }
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Quản lý hệ thống</title>
    <link href="../css/datastyle.css" rel="stylesheet" type="text/css" />
   	<script type="text/javascript" src="../jquery/sdmenu.js"></script>
	<script type="text/javascript">
    	window.onload = function() {
    	myMenu = new SDMenu("my_menu");
    	myMenu.init();
    	};
	</script>
</head>
<body>
    <div id="main">
    <div id="mleft">
				<div id="my_menu" class="sdmenu">
					<div>
						<span>Nhóm nhân viên</span>
							<a href="../Controller/NhomNhanVien.php?Action=List">Danh sách</a>
							<a href="../Controller/NhomNhanVien.php?Action=Append">Thêm</a>
	                        <a href="../Controller/NhomNhanVien.php?Action=Update">Sửa</a>
                            <a href="../Controller/NhomNhanVien.php?Action=Search">Tìm kiếm</a>
                            <a href="../Controller/NhomNhanVien.php?Action=Rule">Phân quyền</a>
					</div>
					<div>
						<span>Nhân viên</span>
							<a href="#">Danh sách</a>
							<a href="#">Thêm</a>
	                        <a href="#">Sửa</a>
                            <a href="#">Tìm kiếm</a>
					</div>
				</div>
    </div>
    <div id="mright">              
        <div class="data_content">
            <div class="guide">
                <div class="guide_con">
                    
                    <div class="nav">
                        <p>QUẢN LÝ HỆ THỐNG</p></div>
                    <div class="guide_line">
                        <div class="guide_center">
                            <div class="top_scroll">
                                <ul class="sub">                               
                                    <?php
                                    $value ="";
                                    if(isset($_GET['Action'])){
                                        $value =$_GET['Action'];
                                    }
                                    else{
                                        header('Location:../Controller/NhomNhanVien.php?Action=List');
                                        exit;
                                    }
                                    if($value==null or $value=="List")
                                        echo '<li id="taskNav1" class="task_1_this"><a href="../Controller/NhomNhanVien.php?Action=List" style="color:white;">Danh sách</a></li>';
                                    else
                                        echo ' <li id="taskNav1" class="task_1"><a href="../Controller/NhomNhanVien.php?Action=List">Danh sách</a></li>';
                                    if($value=="Append")
                                        echo'<li id="taskNav2" class="task_1_this"><a href="../Controller/NhomNhanVien.php?Action=Append" style="color:white;">Thêm</a></li>';
                                    else
                                        echo'<li id="taskNav2" class="task_1"><a href="../Controller/NhomNhanVien.php?Action=Append">Thêm</a></li>';
                                    if($value=="Update")
                                        echo '<li id="taskNav3" class="task_1_this"><a href="../Controller/NhomNhanVien.php?Action=Update" style="color:white;">Sửa</a></li>';
                                    else
                                        echo '<li id="taskNav3" class="task_1"><a href="../Controller/NhomNhanVien.php?Action=Update">Sửa</a></li>';
                                    if($value=="Search")
                                        echo '<li id="taskNav4" class="task_1_this"><a href="../Controller/NhomNhanVien.php?Action=Search" style="color:white;">Tìm kiếm</a></li>';
                                    else
                                        echo '<li id="taskNav4" class="task_1"><a href="../Controller/NhomNhanVien.php?Action=Search">Tìm kiếm</a></li>';
                                    ?>
                            </div>
                            <div>
                                <?php
                                $ma=null;
                                if($value==null or $value=="List"){
                                    $nnv = new NhomNhanVien();
                                   $ok =$nnv->HienThi();
                                    echo "<table border ='1' style='border-collapse:collapse;border-spacing:0;font-family: Arial, sans-serif;font-size: 12px;' BGCOLOR = #DFECFE >
                                            <tr>
                                                <th style='padding:7px;background:#f3f3f3;'><b> Mã nhóm nhân viên </b></th>
                                                <th style='padding:7px;background:#f3f3f3;'><b> Tên nhóm nhân viên </b></th>
                                                <th style='padding:7px;background:#f3f3f3;'><b> Xử lý </b></th>
                                            </tr>";
                                    while($num= mysql_fetch_array($ok))
                                    {
                                        echo "<tr>
                                                <td style='padding:7px;text-align:center;'>".$num['MaNhomNV']."</td>
                                                <td style='padding:7px;'>".$num['TenNhom']."</td>
                                                <td style='padding:7px; background:gray; border-color:black;'><a href='../Controller/NhomNhanVien.php?Action=Update'style='text-decoration:none; color:White;border:2px solid rgb(122, 204, 200); padding:2px 3px 2px 3px;'>Cập nhật</a>
                                                                        <a href='../Controller/NhomNhanVien.php?Action=xoa&Value=".$num['MaNhomNV']."'style='text-decoration:none; color:white;border:2px solid rgb(122, 204, 200);padding:2px 3px 2px 3px;'>Xóa</a>
                                                                        <a href='../Controller/NhomNhanVien.php?Action=List'style='text-decoration:none; color:white;border:2px solid rgb(122, 204, 200);padding:2px 3px 2px 3px;' onClick='HienThiCT()'>Chi tiết</a>
                                                </td>
                                            </tr>";
                                    }
                                    echo "</table>";
                                    } 
                                  if($value=="Append"){
                                    
                                    echo'<form acticon="../Controller/NhomNhanVien.php?Action=List" method="post"><label style="font-family: Arial, sans-serif;font-size: 12px;color:gray;">Tên nhóm nhân viên  </label><input type=text name="AppName"></input> <input type=submit name="App" value="Thêm"></input></form>
                                    ';
                                  }
                                  if($value=="xoa"){
                                    $nnv = new NhomNhanVien();
                                    $ok = $nnv->Xoa($_GET['Value']);
                                    if($ok==1){
                                                header('Location:../Controller/NhomNhanVien.php?Action=List');
                                                setcookie("Success","XoaTC",time()+ 1);
                                                exit;  
                                    }
                                    else{
                                         echo "<script type='text/javascript'>
                                                    alert('Xóa thất bại: ".$ok."');                                         
                                             </script>";   
                                    }
                                  }
                                  if(isset($_POST['App'])){
                                    $nnv = new NhomNhanVien();
                                    $ok = $nnv->Them($_POST['AppName']);
                                    if($ok==1){
                                                header('Location:../Controller/NhomNhanVien.php?Action=List');
                                                setcookie("Success","ThemTC",time()+ 1);
                                                exit;  
                                    }
                                    else{
                                         echo "<script type='text/javascript'>
                                                    alert('Thêm thất bại: ".$ok."');                                         
                                             </script>";   
                                    }
                                  }                                       
                                ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="clear">
            </div>
        </div>
</div>
<div class="clear"></div>
</div>
<div style="display: none">
</div>
</body></html>